package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.math.BigDecimal;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 薪资月统计
 * 
 * @author Jason
 *
 */
@JsonApiResource(type = "salaryreportitem")
@Table(name = "tnb_salary_reportitem")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SalaryReportItem extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime; // 创建时间

	private User createUser;

	private Customer customer;

	private String name; // 员工姓名
	private String idcard; // 保存用户身份证

	private Dicttype staffStatus; // 在职状态

	private Integer onjobDate; // 入职日期
	private Integer regularDate; // 转正日期
	private Integer leaveDate; // 离职日期
	private SalaryReport salaryReport;// 薪资月统计总表
	private BigDecimal probationAmount = BigDecimal.ZERO; // 试用工资
	private BigDecimal regularAmount = BigDecimal.ZERO; // 转正工资
	private BigDecimal baseAmount = BigDecimal.ZERO; // 岗位工资（基本工资）
	private BigDecimal bonusAmount = BigDecimal.ZERO; // 绩效奖金
	private BigDecimal cutAmount = BigDecimal.ZERO; // 绩效扣款
	private BigDecimal otherAmount = BigDecimal.ZERO; // 其它金额

	private Integer leaveDays = 0; // 请假天数（不带薪请假天数）

	@JsonApiToOne
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.SELECT)
	@JoinColumn(name = "salaryReport_id", foreignKey = @ForeignKey(name = "null"))
	public SalaryReport getSalaryReport() {
		return salaryReport;
	}

	public void setSalaryReport(SalaryReport salaryReport) {
		this.salaryReport = salaryReport;
	}

	@Column(name = "idcard", columnDefinition = "varchar(20)")
	public String getIdcard() {
		return idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}

	public Integer getOnjobDate() {
		return onjobDate;
	}

	public void setOnjobDate(Integer onjobDate) {
		this.onjobDate = onjobDate;
	}

	public Integer getRegularDate() {
		return regularDate;
	}

	public void setRegularDate(Integer regularDate) {
		this.regularDate = regularDate;
	}

	public Integer getLeaveDate() {
		return leaveDate;
	}

	public void setLeaveDate(Integer leaveDate) {
		this.leaveDate = leaveDate;
	}

	@Column(name = "probationAmount", columnDefinition = "decimal(12,2) default 0",
			nullable = false)
	public BigDecimal getProbationAmount() {
		return probationAmount;
	}

	public void setProbationAmount(BigDecimal probationAmount) {
		this.probationAmount = probationAmount;
	}

	@Column(name = "regularAmount", columnDefinition = "decimal(12,2) default 0", nullable = false)
	public BigDecimal getRegularAmount() {
		return regularAmount;
	}

	public void setRegularAmount(BigDecimal regularAmount) {
		this.regularAmount = regularAmount;
	}

	@Column(name = "baseAmount", columnDefinition = "decimal(12,2) default 0", nullable = false)
	public BigDecimal getBaseAmount() {
		return baseAmount;
	}

	public void setBaseAmount(BigDecimal baseAmount) {
		this.baseAmount = baseAmount;
	}

	@Column(name = "bonusAmount", columnDefinition = "decimal(12,2) default 0", nullable = false)
	public BigDecimal getBonusAmount() {
		return bonusAmount;
	}

	public void setBonusAmount(BigDecimal bonusAmount) {
		this.bonusAmount = bonusAmount;
	}

	@Column(name = "cutAmount", columnDefinition = "decimal(12,2) default 0", nullable = false)
	public BigDecimal getCutAmount() {
		return cutAmount;
	}

	public void setCutAmount(BigDecimal cutAmount) {
		this.cutAmount = cutAmount;
	}

	@Column(name = "otherAmount", columnDefinition = "decimal(12,2) default 0", nullable = false)
	public BigDecimal getOtherAmount() {
		return otherAmount;
	}

	public void setOtherAmount(BigDecimal otherAmount) {
		this.otherAmount = otherAmount;
	}

	@Column(name = "leaveDays", columnDefinition = "int default 0", nullable = false)
	public Integer getLeaveDays() {
		return leaveDays;
	}

	public void setLeaveDays(Integer leaveDays) {
		this.leaveDays = leaveDays;
	}

	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public SalaryReportItem() {
	}

	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "staffStatus", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getStaffStatus() {
		return staffStatus;
	}

	public void setStaffStatus(Dicttype staffStatus) {
		this.staffStatus = staffStatus;
	}

}
